package com.example.demoexp02;

import javafx.application.Application;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;

@Component
public class NoticeListener implements ApplicationListener<NoticeEvent> {

    @Override
    public void onApplicationEvent(NoticeEvent noticeEvent){
        System.out.println("事件监听器获取到NoticeEvent,睡眠当前线程 2 秒···");
        try{
            TimeUnit.SECONDS.sleep(2);
        }catch (InterruptedException e){
            e.printStackTrace();
        }
        System.out.println("CustomNoticeEvent的message内容是：".concat(noticeEvent.getMessage()));
    }
}
